package br.inatel.ec203.projeto.view;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class ResistorSpecificPanel extends JPanel{

	private static final long serialVersionUID = 2540557804873829693L;
	
	private JLabel materialLabel;
	private JTextField materialTextField;
	
	private GridBagConstraints materialLabelConstraints;
	private GridBagConstraints materialTextFieldConstraints;
	
	public ResistorSpecificPanel () {
		initialize();
	}
	
	private void initialize() {
		setLayout(new GridBagLayout());
		add(getMaterialLabel(), getMaterialLabelConstraints());
		add(getMaterialTextField(), getMaterialTextFieldConstraints());		
	}
	
	public JLabel getMaterialLabel() {
		if (materialLabel == null) {
			materialLabel = new JLabel();
			materialLabel.setText("Material");
		}
		return materialLabel;
	}
	public JTextField getMaterialTextField() {
		if (materialTextField == null) {
			materialTextField = new JTextField();			
		}
		return materialTextField;
	}

	public GridBagConstraints getMaterialLabelConstraints() {
		if (materialLabelConstraints == null) {
			materialLabelConstraints = new GridBagConstraints();
			materialLabelConstraints.gridx = 0;
			materialLabelConstraints.gridy = 0;
			materialLabelConstraints.anchor = GridBagConstraints.LINE_START;
			materialLabelConstraints.insets = new Insets(3, 3, 3, 3);
		}
		return materialLabelConstraints;
	}

	public GridBagConstraints getMaterialTextFieldConstraints() {
		if (materialTextFieldConstraints == null) {
			materialTextFieldConstraints = new GridBagConstraints();
			materialTextFieldConstraints.gridx = 1;
			materialTextFieldConstraints.gridy = 0;
			materialTextFieldConstraints.gridwidth = 3;
			materialTextFieldConstraints.ipadx = 400;
			materialTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL;
			materialTextFieldConstraints.insets = new Insets(3, 3, 3, 3);
			
		}
		return materialTextFieldConstraints;
	}		
	
	public ArrayList<String> getData () {
		
		ArrayList<String> data = new ArrayList<String>();
		
		String material = getMaterialTextField().getText();
		data.add(Util.addInArrayList(material));
		
		return data;
	}
}







